package com.zjc.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zjc.pojo.Bulider;
import com.zjc.pojo.DromAdmin;
import com.zjc.mapper.DromAdminMapper;
import com.zjc.pojo.Student;
import com.zjc.service.BuliderService;
import com.zjc.service.DromAdminService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 周佳成
 * @since 2023-09-17
 */
@Service
public class DromAdminServiceImpl extends ServiceImpl<DromAdminMapper, DromAdmin> implements DromAdminService {
	@Autowired
	BuliderService buliderService;
	@Resource
	DromAdminMapper dromAdminMapper;
	@Override
	public boolean isExistsLd(Integer id) {

		LambdaQueryWrapper<Bulider> lambdaQueryWrapper = new LambdaQueryWrapper<>();
		lambdaQueryWrapper.eq(Bulider::getLdId,id);
		Bulider bulider = buliderService.getOne(lambdaQueryWrapper);
		return bulider!=null;
	}

	@Override
	public boolean isExistsSg(Integer id) {
		LambdaQueryWrapper<DromAdmin> lambdaQueryWrapper = new LambdaQueryWrapper<>();
		lambdaQueryWrapper.eq(DromAdmin::getSgId,id);
		DromAdmin dromAdmin = this.getOne(lambdaQueryWrapper);
		return dromAdmin!=null;
	}

	@Override
	public int deleteSg(Integer id) {
		LambdaQueryWrapper<DromAdmin> lambdaQueryWrapper = new LambdaQueryWrapper<>();
		lambdaQueryWrapper.eq(DromAdmin::getSgId,id);
		return dromAdminMapper.delete(lambdaQueryWrapper);
	}
}
